<?php
namespace app\index\controller;
use think\Controller;
use think\Config;
use think\Cache;
use think\Session;
use think\Cookie;
use think\Db;
use app\common\model\Bang;

class Main extends Controller 
{
    public function index(){
        $host =  $this->request->host(true);
        $ip = $this->request->ip();
        $domain = Db::name('Domain')->where('punycode',$host)->where('status',1)->find();
        if(!empty($domin)){
            $web = Session::get('web');
        }else{
            $web = [];
            $bang = Cache::get(md5($host.$ip));
            if(!empty($bang)){
                $web = Db::name('Web')->where('id',$bang)->find();
            }
        }
        $this->assign('web',$web);
        return $this->view->fetch();
    }
}